package com.resou.reader.mine.vipcenter.adapter;

import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.style.ForegroundColorSpan;
import android.text.style.StrikethroughSpan;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.resou.reader.api.entry.MetMealBean;
import com.resou.reader.R;
import com.resou.reader.data.vip.model.VipPrivilege;
import com.resou.reader.mine.IView.UserInstance;

import java.util.List;

/**
 * Author: 萤火虫
 * E-mail:  Allensuns@163.com
 * Description: VIP套餐
 * CreateTime: 2019-04 -17
 **/
public class VipMetMealAdapter extends BaseQuickAdapter<VipPrivilege.PackageDataBean, BaseViewHolder> {
    public VipMetMealAdapter(int layoutResId, @Nullable List<VipPrivilege.PackageDataBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, VipPrivilege.PackageDataBean item) {

        helper.addOnClickListener(R.id.rlOnclick).addOnClickListener(R.id.cbCheckBox)
                .setText(R.id.tvTime, item.getVip_day() + "")
                .setText(R.id.tvMoney,
                        "¥" + item.getLineation_price())
                .setText(R.id.tvCoupon, item.getVoucher() + "热券")
                .setText(R.id.tvPresentPrice, "¥" + item.getActivity_price() + "")
                .setChecked(R.id.cbCheckBox, item.isCheck())
                .setVisible(R.id.tvCoupon, false);
        setLine(helper.getView(R.id.tvMoney));
        if ("0".equals(item.getVoucher())) {
            helper.setText(R.id.tvDes, item.getIntro_message() + "");
            helper.setVisible(R.id.tvCoupon, false);
        } else {
            helper.setText(R.id.tvDes, "另赠送");
            helper.setVisible(R.id.tvCoupon, true);
        }
    }

    /**
     * 设置删除线
     *
     * @param tv_text
     */
    private void setLine(TextView tv_text) {
        tv_text.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG); //删除线
        tv_text.getPaint().setAntiAlias(true);// 抗锯齿
    }
}
